<?php
namespace app\common\model;

use think\Model;

/**  YSF
 *   分享模型
 *   Date: 2018/11/29
 * Class SharingModel
 * @package app\common\model
 */
class SharingModel extends Model
{
    // 表名
    protected $name = 'sharing';

    // 列表查询
    public function getAll($where=[],$field='*',$page=1,$pageSize=-1,$order='')
    {
		if($pageSize<0){
			 $result = $this->where($where)
                ->field($field)
                ->order($order)
                ->select();
		}else{
			 $result = $this->where($where)
                ->field($field)
                ->page($page, $pageSize)
                ->order($order)
                ->select();
		}
       
        return $result;
    }

    // 数量查询
    public function getCount($where=[])
    {
        $result = $this->where($where)->count();
        return $result;
    }

    // 添加操作
    public function add($data=[])
    {
        $result = $this->allowField(true)->insertGetId($data);
        return $result;
    }

    // 编辑操作
    public function edit($where=[],$data=[])
    {
        $result = $this->where($where)->update($data);
        return $result;
    }

    // 单条查询
    public function getOne($where=[],$field='*')
    {
        $result = $this->where($where)->field($field)->find();
        return $result;
    }

    // 删除操作
    public function del($where=[])
    {
        $result = $this->where($where)->delete();
        return $result;
    }





}